package com.xuecheng.content.controller;

import com.xuecheng.api.content.AuditControllerApi;
import com.xuecheng.api.content.model.dto.AuditDto;
import com.xuecheng.api.content.model.dto.CourseBaseDTO;
import com.xuecheng.api.content.model.qo.QueryCourseModel;
import com.xuecheng.api.content.model.vo.AuditVo;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.content.convert.AuditConvert;
import com.xuecheng.content.service.AuditService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 黄子弟
 * @Date 2021/12/13
 */

@Slf4j
@RestController
public class AuditController implements AuditControllerApi {

    @Autowired
    private AuditService auditService;

    @Override
    @PostMapping("/m/course/list")
    public PageVO<CourseBaseDTO> queryAuditList(PageRequestParams params, @RequestBody QueryCourseModel model) {
        PageVO<CourseBaseDTO> pageVO = auditService.queryAuditList(params, model);
        return pageVO;
    }

    @Override
    @PostMapping("/m/courseReview/approve")
    public void modifyAuditStatus(@RequestBody AuditVo auditVo) {
        //vo装dto
        AuditDto auditDto = AuditConvert.INSTANCE.vo2dto(auditVo);
        auditService.modifyAuditStatus(auditDto);
    }
}
